package cn.servlet;

import cn.dao.StaffDao;
import cn.dao.StaffDaoImpl;
import cn.entity.Staff;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/reload")
public class ReloadServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = Integer.parseInt(req.getParameter("id"));
        StaffDao dao = new StaffDaoImpl();
        Staff staff = dao.findID(id);
        req.setAttribute("staff", staff);//设置属性值在同一个请求范围内的JSP页面中使用
        req.getRequestDispatcher("updateStaff.jsp").forward(req, resp);
    }
}